package us.icitap.cm.utils.convertes;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;

import com.vaadin.data.util.converter.Converter;


@SuppressWarnings("rawtypes")
public class MyListToSetConverter implements Converter<Set, List> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5181319528978896171L;

//	@SuppressWarnings("unchecked")
//	@Override
//	public List convertToModel(Set value, Locale locale)
//			throws com.vaadin.data.util.converter.Converter.ConversionException {
//		if(value == null) return null;
//		return new ArrayList(value);
//		
//	}
//
//	@SuppressWarnings("unchecked")
//	@Override
//	public Set convertToPresentation(List value, Locale locale)
//			throws com.vaadin.data.util.converter.Converter.ConversionException {
//		
//		if(value == null) return null;
//		return new HashSet(value);
//		
//	}

	@Override
	public Class<List> getModelType() {
		// TODO Auto-generated method stub
		return List.class;
	}

	@Override
	public Class<Set> getPresentationType() {
		// TODO Auto-generated method stub
		return Set.class;
	}

	@Override
	public List convertToModel(Set value, Class<? extends List> targetType,
			Locale locale)
			throws com.vaadin.data.util.converter.Converter.ConversionException {
		if(value == null) return null;
		return new ArrayList(value);
	}

	@Override
	public Set convertToPresentation(List value,
			Class<? extends Set> targetType, Locale locale)
			throws com.vaadin.data.util.converter.Converter.ConversionException {
		if(value == null) return null;
		return new HashSet(value);
	}


}
